package com.qidianit.mes.pro.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.qidianit.mes.common.Result;
import com.qidianit.mes.pro.service.ProductionTaskService;
import com.qidianit.mes.pojo.pro.ProductionTask;

import java.util.List;

/**
 * Package Path: com.qidianit.mes.pro.controller
 * Author: Alhz
 * Description:
 * Date: 2025/9/24 14:29
 */
@RestController
@RequestMapping("/productionTask")
public class ProductionTaskController {
    @Autowired
    private ProductionTaskService productionTaskService;

    @GetMapping("/PageList")
    public Result selectAllProductionTask( @RequestParam(defaultValue = "1") Integer page,
                                           @RequestParam(defaultValue = "10") Integer pageSize) {
        return productionTaskService.selectAllProductionTask(page,pageSize);
    }


    @GetMapping("/list")
    public Result selectAllProductionOrders(Integer productionOrderId,
                                            Integer processId,
                                            @RequestParam(defaultValue = "1") Integer page,
                                            @RequestParam(defaultValue = "10") Integer pageSize){
        return productionTaskService.selectAllProductionOrders( productionOrderId, processId,page, pageSize);
    }

    @GetMapping("/{id}")
    public Result getProductionTaskById(@PathVariable Long id){
        return productionTaskService.getProductionTaskById(id);
    }
    
    @PostMapping("/add")
    public Result addProductionTask(@RequestBody ProductionTask productionTask){

        System.out.println(productionTask);
        return productionTaskService.addProductionTask(productionTask);
    }
    
    @PutMapping("/update")
    public Result updateProductionTask(@RequestBody ProductionTask productionTask){
        return productionTaskService.updateProductionTask(productionTask);
    }
    
    @DeleteMapping("/delete/{id}")
    public Result deleteProductionTask(@PathVariable Long id){
        return productionTaskService.deleteProductionTask(id);
    }
    
    @DeleteMapping("/batchDelete")
    public Result batchDeleteProductionTasks(@RequestBody List<Long> ids){
        return productionTaskService.batchDeleteProductionTasks(ids);
    }
    
}
